-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide default values information in generated config file, better handle logging default parameters #3053
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for taking a look at this.
I'm not sure this actually solves the underlying problem though.
#3002 is about having less config file and relying on defaults. Whereas these changes actually increases the size of the generated config file.
These additional lines in the config file are an additional thing to keep updated as config changes and evolves over time.
Ideally all this config, specifically the default config would be sourced from one single "source of truth".
For example if we make the decision to change the default port -
#the address on which services will listen, e.g. Transaction Pool
#Default: 127.0.0.1:3413
We would have to remember to change the text in this "Default" line in the config file comments.
I suspect #3002 would be solved by taking a look at how we currently handle default values and taking better advantage of "serde defaults". We are inconsistent in how we handle this in different parts of the code.
The way we should be handling defaults (and non-required values in the config file itself) -
Lines 51 to 54 in 1c072f5
pub struct DandelionConfig { | |
/// Length of each "epoch". | |
#[serde(default = "default_dandelion_epoch_secs")] | |
pub epoch_secs: u16, |
This defines a config entry and defines a fn to call if the value is not present in the config file.
This removes the need to wrap anything in an Option<>
and we don't need special case handling of None
if its missing.
And then in comments.rs we can reuse this same fn to generate a "default" comment line describing what the default value is. Ideally as a commented out config line that can be easily un-commented out.
Ok I get your point, fair request indeed. I can confirm "serde defaults" are not used everywhere (mostly in one place if I remember well). I'll look into improving this first. I don't think @josef-v was concerned with the size of the default configuration file as long as he can trim it himself without breaking things. If you think there is a better place to extract and expose the default config values, I'll be happy to look into it. |
I agree with @glemercier that adding another comment is not an issue as you can simply delete it later without any consequences. So having defaults in a comment is ok, maybe unnecessary as we can have the config file generated with defaults and some statement "config file generated with default values" on top of it. However hardcoding these values into config is not a way to go.
That's exactly what I meant. |
Thank you both for your feedback and implementation details. I'll work on this and propose an update to this PR. |
Update to the PR:
instead of previously
however it is possible to comment the line in the new case and it will take the default value, which was not possible the old way (using derived Serialize/Deserialize)
Feel free to provide feedback on this PR and suggest any change. |
Planning to take a closer look over this over the next couple of days. But 👍 on the approach. |
@antiochp this one has accumulated quite a bit of conflicts. Is the proposed change still relevant? |
Closed and marked as 'abandoned'. This does not mean the PR is unworthy. This means that merging it would require further work that nobody appears prepared to do at this time, or the original author has been unresponsive for a significant amount of time. Anyone who want to continue work on this functionality is free to re-open this at any time. |
Improvements linked to request #3002
This pull request provides information on default values for each config parameter as comments of the auto-generated
grin-server.toml
file, as per requested in issue mentioned above.It also better handles cases where some logging parameters are not provided, leading to the program exiting. Instead we use optional parameters set to their default value when absent from the config file.
This PR improves overall configuration experience based on @josef-v feedback but it could be amended to better improve simple configuration inconsistencies coming from anyone else's request.